//
//  BaseTabBarController.m
//  Project
//
//  Created by 本游网络 on 2017/12/19.
//  Copyright © 2017年 本游网络. All rights reserved.
//

#import "BaseTabBarController.h"
#import "Utility.h"
#import "DataHomeViewController.h"
#import "BaseNavigationViewController.h"

@interface BaseTabBarController ()<UITabBarControllerDelegate>
@property (nonatomic, assign) NSInteger continuoseSelectedCount;
@property (nonatomic,assign)NSInteger lastTimestamp;
@property (nonatomic,assign)NSInteger countPerFrame;
@end

@implementation BaseTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.delegate = self;
    if ([Utility isAppInReview]) {
        [self setupDefaultViewControllers];
    } else {
        [self getTabInfo];
    }
}
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
      [self showSplash];
    });
}

- (void)setContinuoseSelectedCount:(NSInteger)continuoseSelectedCount {
    _continuoseSelectedCount = continuoseSelectedCount;
    if (continuoseSelectedCount >= 10) {
        self.continuoseSelectedCount = 0;
        [self getTabInfo];
    }
}

// 在首页展示的页面
- (void)showSplash {
   //登录页面
}
//动态设置tabbar
- (void)getTabInfo {
    
}

//设置默认的tabbar
- (void)setupDefaultViewControllers{
    NSMutableArray *array = [NSMutableArray array];
    BaseNavigationViewController *discvoeryNavigationController = [[BaseNavigationViewController alloc]initWithRootViewController:[[DataHomeViewController alloc]init]];
    discvoeryNavigationController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"数据统计" image:[UIImage imageNamed:@"home"] selectedImage:[UIImage imageNamed:@"homeSelect"]];
    discvoeryNavigationController.navigationBar.hidden = YES;
    [array addObject:discvoeryNavigationController];
    
    self.viewControllers = array;
    self.selectedIndex = 0;
    self.continuoseSelectedCount = self.selectedIndex;
//    self.tabBar.tintColor = [UIColor colorWithHexString:MAINCOLOR];
    [[UINavigationBar appearance] setTranslucent:NO];
    [UINavigationBar appearance].translucent = NO;
 
  
}
#pragma mark - <UITabBarControllerDelegate>
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
    if ([tabBarController.selectedViewController isEqual:viewController]) {
        self.continuoseSelectedCount += 1;
    } else {
        self.continuoseSelectedCount = 0;
    }
    return YES;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
